package cn.tqfeiyang.smartadmin.commons.mybatis;

/**
 * 实体监视器
 *
 * @author tqfeiyang
 * @since 2024/9/26 10:10
 */
public interface IEntityListener<T> {

    default void beforeCreate(T entity) {
        beforeChange(entity, true);
    }

    default void afterCreate(T entity) {
        afterChange(entity, true);
    }

    default void beforeUpdate(T entity) {
        beforeChange(entity, false);
    }

    default void afterUpdate(T entity) {
        afterChange(entity, false);
    }

    default void beforeChange(T entity, boolean creating) {}

    default void afterChange(T entity, boolean creating) {}

    default void beforeDelete(T entity) {}

    default void afterDelete(T entity) {}

}
